var App = require('app');

App.FormDisplayView = Em.View.extend({
    templateName: 'templates/form/display',
    didInsertElement: function() {
    	var me = this;
    	me.displayForm(); 	
        
    },
    displayForm: function() {
    	var i = 1;
		Vari.frm.fields.forEach(function(field) {
			Ember.mixin(field, {
				indexx: i++
			});
			var type = field.type;
			var utilName = Util.capFirstLetter(type) + "Util";
			var cmd = utilName + ".view(field)";
			eval(cmd);
		});
		
		$("#formId").val(Vari.frm.get("id"));
		$("#headline").text(Vari.frm.get("headline"));
		
		$("#submit").width($("#form_canvas_view").width() - 10 + "px");	
	
		$("#form_canvas_view").on(Paging.pagingEvents, ".fieldset.pageBreak .hasPrevious, .fieldset.pageBreak .hasNext");	
    }
});